import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import refresh from '@dfeidao/atom-web/url/refresh';
import confirm from '@dfeidao/atom-web/msgbox/confirm';
import { ConfirmResult } from '@dfeidao/atom-web/msgbox/confirm';

export default async function a008(fd: IFeidaoAiBrowserComponent, e: Event) {
	// todo
	const de = e.currentTarget as HTMLInputElement;
	const del = de.getAttribute('data-no');
	console.log('deldel', del);

	const flag = await confirm('确定删除吗', '删除', '确定', '取消', 'red');
	switch (flag) {
		case ConfirmResult.YES:
			const res = await nodejs<{ code: 0 | 1, result: string }>('company-factory/zj-000006/s005', {
				filter: {
					factory_no: del
				}
			});
			console.log(res.code);
			if (res.code === 1) {
				alert("删除成功");
				refresh();
			} else {
				alert("删除失败");
			}
			// todo
			break;
		case 'no':
			// todo
			break;
		default:    // cancel
			// todo
			break;
	}
}
